package main

import (
	"fmt"
	"time"
)

func main() {
	// c := make(chan int) // 无缓冲区 channel
	c := make(chan int, 5) // 缓冲区 channel
	for i := 0; i < 20; i++ {
		c <- i
		go func() {
			fmt.Println("do something:", i)
			<-c
		}()
	}

	time.Sleep(time.Second * 2) // 为了防止 main goroutine 提前退出
}
